#include "tree.h"
#include "memory.h"
#ifndef __symbol_h
#define __symbol_h
#define HashSize 317

/* SYMBOL will be extended later.
 Function calls will take more parameters later.
 */

typedef struct SYMBOL {
	char *name;
	enum {
		typeSK, functionSK, variableSK
	} kind;
	struct SYMBOL *next;
	int pos;
	union {
		struct TYPE *type;
		struct FUNCTION *function;
		struct VAR_TYPE *var_type;
	} val;
} SYMBOL;

typedef struct SymbolTable {
	SYMBOL *table[HashSize];
	struct SymbolTable *next;
} SymbolTable;
int Hash(char *str);

SymbolTable *initSymbolTable();

SymbolTable *scopeSymbolTable(SymbolTable *t);

SYMBOL *putSymbolType(SymbolTable *t, char *name, TYPE *type);
SYMBOL *putSymbolFunction(SymbolTable *t, char *name, FUNCTION *function);
SYMBOL *putSymbolVariable(SymbolTable *t, char *name, VAR_TYPE *var_type);

SYMBOL *getSymbol(SymbolTable *t, char *name);

void dumpSymbolTable(SymbolTable *t);
#endif
